package com.warmhearted.SmsAnnouncingService;



import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import android.app.PendingIntent.OnFinished;

public class IncomingSMSReceiver extends BroadcastReceiver  {

	private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
	
	
	@Override
	public void onReceive(Context _context, Intent _intent) {
		//gets activated when a new SMS is Received
		
			if (_intent.getAction().equals(SMS_RECEIVED)) {
				
				//show a toast to indicate arrival of SMS
				CharSequence text = "NEW SMS RECEIVED";
				int duration = Toast.LENGTH_SHORT;
				Toast toast = Toast.makeText(_context, text, duration);
				toast.show();
				//show a toast to indicate arrival of SMS
				
				
				//start a service which creates Physical Notification
				//start the service SmsMessageNotificationService
				Intent smsIntent = new Intent(_context,SmsMessageNotificationService.class);
				smsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				_context.startService(smsIntent);	
				
		}//if loop
	}//onReceive
}//IncomingSMSReceiver

